package thread;

import lombok.Data;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author ycz
 * @date 2021/5/31
 * @description TODO
 *
 */
@Data
public class MyThread implements Runnable {

    ReentrantLock reentrantLock = new ReentrantLock();

    volatile int sum = 0;

    static int add = 0;

    public static void main(String[] args) {

        MyThread myThreadPool = new MyThread();
        for (int i = 0; i < 10; i++) {
            new Thread(myThreadPool).start();
        }
    }


    @Override
    public void run() {
        synchronized (this) {
            for (int i = 0; i < 100000; i++) {
                ++add;
                ++sum;
            }
            System.out.println(add);
            System.out.println("sum====" + sum);
        }
    }
}
